package com.yurui.proxy.jdk;

import java.lang.reflect.Proxy;

public class Client {

    public static void main(String[] args) {
        HouseSubject houseSubject = new RealHouseSubject();
        LogAdvice logAdvice = new LogAdvice();
        HouseSubject proxy = (HouseSubject) Proxy.newProxyInstance(houseSubject.getClass().getClassLoader(),
                houseSubject.getClass().getInterfaces(),
                new MyHandler(houseSubject,logAdvice));
        proxy.rentHouse();
        proxy.buyHouse();
        System.out.println(proxy.sellHouse());
    }
}
